<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

/**
 * Add any string to the form within a defined long tag
 * @author Anthony Gallon
 * @package Antz
 */

/**
 * Add any string to the form within a defined long tag
 * @author Anthony Gallon
 * @package Antz
 */
class JFX_Form_Components_LongTag extends JFX_Form_Component
{
    /**
     * The name of the long tag
     * @var string $tagname
     */
    protected $tagname = 'p';
    /**
     * Text to go inside the tag
     * @var string $text
     */
    protected $text = '';

    /**
     * Set the initial values
     * @param string $tagname
     * @param string $text
     */
    public function __construct($tagname, $text=''){
        $this->tagname = $tagname;
        $this->text = $text;
    }

    /**
     * Get the element as an HTML string
     * @return string $html
     */
    public function render(){
        $closeTag = explode(' ', $this->tagname);
        $closeTag = $closeTag[0];
        $returnString = '';
        $returnString .= '<'.$this->tagname.' '.$this->renderClasses().' id="'.$this->getId().'" '.$this->renderParameters().'>'."\n  "
            .$this->text."\n".'</'.$closeTag.'><!-- end'.$this->renderClasses().' -->';
        
        if($this->wrap) $returnString = $this->wrap($returnString);
        
        return $returnString;

    }

}
